//package com.example.demo.web.controller;
//
//import com.example.demo.entity.User;
//import com.example.demo.mapper.UserMapper;
//import com.example.demo.sharding.DBShardingStrategy;
//import com.example.demo.sharding.TableShardingStrategy;
//import jakarta.annotation.Resource;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import reactor.core.publisher.Flux;
//import reactor.core.publisher.Mono;
//
//import java.util.List;
//
//@RestController
//@RequestMapping("/users")
//public class MyRestController {
//
//    @Resource
//	private UserMapper userMapper;
//
//	@GetMapping("/user/{userId}")
//	//@PrePermission("admin")
//	//@PreAuthorize("hasAnyAuthority('admin')")
//	public Mono<User> getUser(@PathVariable Long userId) {
//		TableShardingStrategy.shardTableLocal.set(userId);
//		DBShardingStrategy.dbLocal.set("slave");
//        com.example.demo.entity.User user = userMapper.selectOneById(userId);
//        return Mono.justOrEmpty(user);
//	}
//
//	@GetMapping("/all")
//	//@PrePermission("hr")
//	public Flux<User> getUsers() {
//		DBShardingStrategy.dbLocal.set("master");
//		List<User> all = userMapper.selectAll();
//		return Flux.fromIterable(all);
//	}
//
//	@GetMapping("/delete/{userId}")
//	public Mono<Void> deleteUser(@PathVariable Long userId) {
//		return Mono.empty();
//	}
//
//}
